package com.xybc.impl;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.xybc.entity.product;
import com.xybc.entity.proType;
import com.xybc.util.DBManager;
import com.xybc.util.QueryResult;

public class ProductImpl {

	public List<proType> selectProductType(){
		 String sql ="select * from producttype";
		 QueryResult qr=DBManager.executeQuery(sql);
		List<proType> list= new ArrayList<proType>();
		 if(qr!=null) {
			 try {
				while(qr.rs.next()) {
					proType proty=new proType(qr.rs.getInt(1),qr.rs.getString(2));	 
				list.add(proty);
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		 }
		 qr.close();
		 return list;
	 }
	
	public List<product> selectProduct(){
		 String sql ="select * from product";
		 QueryResult qr=DBManager.executeQuery(sql);
		List<product> list= new ArrayList<product>();
		 if(qr!=null) {
			 try {
				while(qr.rs.next()) {
					product pro=new product(qr.rs.getInt(1),qr.rs.getString(2),qr.rs.getString(3),qr.rs.getString(4),
							qr.rs.getString(4),qr.rs.getString(5),qr.rs.getInt(7),qr.rs.getString(8),
							qr.rs.getString(9));	 
				list.add(pro);
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		 }
		 qr.close();
		 return list;
	 }
}